package com.mew.slots.core.game.tjcs.service;

import com.mew.common.enm.SlotsWinType;
import com.mew.common.entity.game.WinFree;
import com.mew.slots.core.common.game.BaseGameService;
import com.mew.slots.core.common.game.vo.BasePlayMsgs;
import com.mew.slots.core.common.messge.response.SlotsPlayResponseMessage;
import com.mew.slots.core.common.vo.StrategyGameVO;
import com.mew.slots.core.game.tjcs.roller.TjcsIli;
import com.mew.slots.core.game.tjcs.roller.TjcsXml;
import com.mew.slots.core.game.tjcs.room.TjcsRoom;

public class TjcsService extends BaseGameService {

    @Override
    public BasePlayMsgs startGame(StrategyGameVO player) {

        TjcsRoom room = new TjcsRoom(player.getWinFree().getFreeRate());
        room.init(player.getRollerId(), TjcsIli.getInstance(),player.getWinType()==SlotsWinType.Free.code(),player.getInBetNumber(),player.getControlType());
        room.roundPlayIli();
        return room.getRes();
    }

    @Override
    public SlotsPlayResponseMessage myResp(WinFree winFree, BasePlayMsgs res) {
        if(winFree.getFrees()>0&&winFree.getFreeNumber()==1){
            winFree.setFreeType(0);
            winFree.setFreeRate(0);
        }

        return new SlotsPlayResponseMessage();
    }

    @Override
    public void myAfterResp(SlotsPlayResponseMessage message,StrategyGameVO player, BasePlayMsgs res) {
        if(res.getFree()>0&&player.getWinType()==SlotsWinType.Free.code()){
            res.setFree((byte) 0);
        }
    }

}
